//
//  YYUserFeedbackVC.m
//  Project
//
//  Created by Yown on 2024/2/5.
//

#import "YYUserFeedbackVC.h"
#import "YYUserFeedbackView.h"
#import "YYFeedBackTypeModel.h"

#import <BINetworkModule/BINetworkManager.h>
#import <BIProjectModule/BIAppDefine.h>

#import <Masonry/Masonry.h>

@interface YYUserFeedbackVC ()

@property (nonatomic) YYUserFeedbackView *feedbackView;
@property (nonatomic, copy) NSArray <YYFeedBackTypeModel *>*modelArray;

@end

@implementation YYUserFeedbackVC

#pragma mark - Life Cycle

+ (void)load {
    [[BIRouteManager sharedInstance] registerCMD:@"user_feedback" objectOrClass:self];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupData];
    [self setupView];
    [self setupLayout];
}

- (void)setupData {
    self.modelArray = [NSMutableArray array];
    
    [self getFeedbackType];
}

- (void)setupView {
    self.yy_navigationItem.title = BILocalizedString(@"user_feedback_title");
    self.yy_navigationBar.naviBgColor = [UIColor loadColorFromString:@"#F6F6F6"];
    
    self.feedbackView = [YYUserFeedbackView view];
    [self.view addSubview:self.feedbackView];
}

- (void)setupLayout {
    [self.feedbackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(BINavigationBarHeight);
    }];
}

#pragma mark - Network

- (void)getFeedbackType {
    NSString *path = @"/api/app/feedback/getFeedbackType";
    BINetworkRequest *request = [[BINetworkManager sharedInstance] requestWithPath:path arguments:nil succeedBlock:^(BINetworkResponse *response) {
        self.modelArray = [NSArray modelArrayWithClass:[YYFeedBackTypeModel class] json:response.modelValue];
        [self.feedbackView reloadType:self.modelArray];
    } failureBlock:nil completionBlock:nil];
    request.methodType = kBINetworkGetMethodType;
    [[BINetworkManager sharedInstance] startRequest:request];
}

@end
